#!/bin/bash

SVN_PATH_ON_DISK="/usr/src/trunk"
TEMP_PATH="/usr/src/submit_temp"
HW_NAME="hw2"
KERNEL_PATH=$HW_NAME
EXTRA_FILES_PATH="tools/submitters.txt ${HW_NAME}_test/tester/sched_tester.c ${HW_NAME}_test/tester/tester_results.txt ${HW_NAME}_test/${HW_NAME}_syscalls.h"
OUTPUT_ZIP="${SVN_PATH_ON_DISK}/submissions/${HW_NAME}_308878438.zip"

cd $SVN_PATH_ON_DISK
#svn update

if [ -d $TEMP_PATH ]; then
	rm -r $TEMP_PATH
fi

mkdir -p ${TEMP_PATH}/zip_temp

svn export $KERNEL_PATH ${TEMP_PATH}/kernel

cp $EXTRA_FILES_PATH ${TEMP_PATH}/zip_temp

cd $TEMP_PATH/kernel

bash -c "tar -cvzf ../zip_temp/kernel.tar.gz *"

cd $TEMP_PATH/zip_temp 

bash -c "zip $OUTPUT_ZIP *"

echo "All Done!"
